Skip to content

fix: pad auto-generated username/name to minimum 3 characters - #57

Merged
yash-pouranik merged 4 commits into
mainfrom
copilot/fix-auto-generated-username-length
Mar 28, 2026
Merged

fix: pad auto-generated username/name to minimum 3 characters#57
yash-pouranik merged 4 commits into
mainfrom
copilot/fix-auto-generated-username-length

Conversation

Copilot AI commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

buildAuthUserPayload derives name and username from the email prefix when those fields are required but absent — e.g. a@b.com"a", which undercuts the ≥3-char minimum enforced in updateProfile.

Changes

  • Both public-api and dashboard-api userAuth.controller.js: Extract the derived value into a variable and apply padEnd(3, '0') when its length is under 3, applied consistently to both the name and username auto-generation blocks.
// Before
payload.username = payload.name || email.split('@')[0];

// After
const generatedUsername = payload.name || email.split('@')[0];
payload.username = generatedUsername.length >= 3
    ? generatedUsername
    : generatedUsername.padEnd(3, '0');

Applies the same guard to the name fallback block for consistency.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@vercel

vercel Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ur-backend-web-dashboard Ready Ready Preview, Comment Mar 28, 2026 9:21am

Copilot AI changed the title [WIP] Fix auto-generated username from email prefix to meet length requirement fix: pad auto-generated username/name to minimum 3 characters Mar 28, 2026
Copilot AI requested a review from yash-pouranik March 28, 2026 09:14
@yash-pouranik
yash-pouranik marked this pull request as ready for review March 28, 2026 09:15
Copilot AI review requested due to automatic review settings March 28, 2026 09:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates buildAuthUserPayload in both API services to ensure auto-generated name / username values derived from the email prefix meet a minimum length of 3 characters, aligning with downstream username length requirements.

Changes:

  • Auto-generate name from username or email prefix, padding to 3 chars when needed.
  • Auto-generate username from payload.name or email prefix, padding to 3 chars when needed.
  • Apply the same logic in both public-api and dashboard-api controller implementations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/public-api/src/controllers/userAuth.controller.js Pads derived name/username to at least 3 characters during signup/admin-create flows.
apps/dashboard-api/src/controllers/userAuth.controller.js Mirrors the same minimum-length padding behavior for derived name/username.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/public-api/src/controllers/userAuth.controller.js Outdated
Comment thread apps/dashboard-api/src/controllers/userAuth.controller.js Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yash-pouranik
yash-pouranik temporarily deployed to copilot/fix-auto-generated-username-length - urBackend-frankfrut PR #57 March 28, 2026 09:20 — with Render Destroyed
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yash-pouranik
yash-pouranik temporarily deployed to copilot/fix-auto-generated-username-length - urBackend-frankfrut PR #57 March 28, 2026 09:21 — with Render Destroyed
@yash-pouranik
yash-pouranik merged commit 1bfdff6 into main Mar 28, 2026
5 checks passed
yash-pouranik added a commit that referenced this pull request Apr 18, 2026
…outes

- fix(dashboard-api): create `publicLimiter` for non-sensitive data queries
- fix(dashboard-api): apply `publicLimiter` to `GET /api/waitlist/count` endpoint
- fix(dashboard-api): apply strict `authLimiter` to `GET /api/waitlist/admin` endpoint
- chore: address CodeQL alerts #55, #56, #57 regarding missing rate limiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: auto-generated username from email prefix can be shorter than 3 chars

3 participants